function success(info,time) { 
    if (info == undefined) { 
        info = '操作成功!';  // 若info为空，则默认返回操作成功
    }
    if (time == undefined) {
        time = 1500;  // 若time为空，则默认返回1500ms
    }

    // 检查是否已经存在成功的提示框
    if (document.querySelector('.alert_success')) {
        return;
    }
    
    let box_alert = document.createElement('div');
    box_alert.innerHTML = `<div class="alert_success"><span class="iconfont icon-chenggong"></span>${info}</div>`;
    document.body.append(box_alert);
    setTimeout(() => {
        document.body.removeChild(box_alert);
    }, time);
}

function failure(info,time) { 
    if (info == undefined) { 
        info = '操作失败!';  // 若info为空，则默认返回操作失败
    }
   if (time == undefined) {
        time = 1500;  // 若time为空，则默认返回1500ms
    }
    // 检查是否已经存在失败的提示框
    if (document.querySelector('.alert_failure')) {
        return;
    }

    let box_alert = document.createElement('div');
    box_alert.innerHTML = `<div class="alert_failure"><span class="iconfont icon-chucuo"></span>${info}</div>`;
    document.body.append(box_alert);
    setTimeout(() => {
        document.body.removeChild(box_alert);
    }, time);
}

function warning(info,time) { 
    if (info == undefined) { 
        info = '警告!';  // 若info为空，则默认返回警告
    }
    if (time == undefined) {
        time = 1500;  // 若time为空，则默认返回1500ms
    }
    // 检查是否已经存在警告的提示框
    if (document.querySelector('.alert_waring')) {
        return;
    }

    let box_alert = document.createElement('div');
    box_alert.innerHTML = `<div class="alert_waring"><span class="iconfont icon-jinggao"></span>${info}</div>`;
    document.body.append(box_alert);
    setTimeout(() => {
        document.body.removeChild(box_alert);
    }, time);
}

export { success, failure, warning };